import { Http,Util,HttpResponse } from '@/ibiz-core/utils';
import  { EntityService }  from '@/ibiz-core';



/**
 * 商家入驻审核表服务对象基类
 *
 * @export
 * @class Shop_examineServiceBase
 * @extends {EntityServie}
 */
export class Shop_examineServiceBase extends EntityService {

    /**
     * Creates an instance of  Shop_examineServiceBase.
     * 
     * @param {*} [opts={}]
     * @memberof  Shop_examineServiceBase
     */
    constructor(opts: any = {}) {
        super(opts);
    }

    /**
     * 初始化基础数据
     *
     * @memberof Shop_examineServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='shop_examine';
        this.APPDEKEY = 'id';
        this.APPDENAME = 'shop_examines';
        this.APPDETEXT = 'examine_shop_name';
        this.APPNAME = 'app';
        this.SYSTEMNAME = 'dqgfy';
    }

// 实体接口

    /**
     * Agree接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async Agree(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
            let res:any = Http.getInstance().post(`/shop_examines/${context.shop_examine}/agree`,data,isloading);
            return res;
    }

    /**
     * CheckKey接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
            let res:any = Http.getInstance().post(`/shop_examines/${context.shop_examine}/checkkey`,data,isloading);
            return res;
    }

    /**
     * Create接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        let masterData:any = {};
        let securityinfosData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_securityinfos'),'undefined')){
            securityinfosData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_securityinfos') as any);
            if(securityinfosData && securityinfosData.length && securityinfosData.length > 0){
                securityinfosData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.id = null;
                            if(item.hasOwnProperty('id') && item.id) item.id = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.securityinfos = securityinfosData;
        let security_infomsData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_security_infoms'),'undefined')){
            security_infomsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_security_infoms') as any);
            if(security_infomsData && security_infomsData.length && security_infomsData.length > 0){
                security_infomsData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.id = null;
                            if(item.hasOwnProperty('id') && item.id) item.id = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.security_infoms = security_infomsData;
        Object.assign(data,masterData);
        if(!data.srffrontuf || data.srffrontuf !== "1"){
            data[this.APPDEKEY] = null;
        }
        if(data.srffrontuf){
            delete data.srffrontuf;
        }
        let tempContext:any = JSON.parse(JSON.stringify(context));
        let res:any = await Http.getInstance().post(`/shop_examines`,data,isloading);
        this.tempStorage.setItem(tempContext.srfsessionkey+'_securityinfos',JSON.stringify(res.data.securityinfos?res.data.securityinfos:[]));
        this.tempStorage.setItem(tempContext.srfsessionkey+'_security_infoms',JSON.stringify(res.data.security_infoms?res.data.security_infoms:[]));
        
        return res;
    }

    /**
     * Get接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
            let res:any = await Http.getInstance().get(`/shop_examines/${context.shop_examine}`,data);
                        this.tempStorage.setItem(context.srfsessionkey+'_securityinfos',JSON.stringify(res.data.securityinfos?res.data.securityinfos:[]));
            this.tempStorage.setItem(context.srfsessionkey+'_security_infoms',JSON.stringify(res.data.security_infoms?res.data.security_infoms:[]));

            return res;
    }

    /**
     * GetDraft接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        let res:any = await  Http.getInstance().get(`/shop_examines/getdraft`,isloading);
        res.data.shop_examine = data.shop_examine;
                    this.tempStorage.setItem(context.srfsessionkey+'_securityinfos',JSON.stringify(res.data.securityinfos?res.data.securityinfos:[]));
            this.tempStorage.setItem(context.srfsessionkey+'_security_infoms',JSON.stringify(res.data.security_infoms?res.data.security_infoms:[]));

        return res;
    }

    /**
     * ReSubmit接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async ReSubmit(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
            let res:any = Http.getInstance().post(`/shop_examines/${context.shop_examine}/resubmit`,data,isloading);
            return res;
    }

    /**
     * Refuse接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async Refuse(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
            let res:any = Http.getInstance().post(`/shop_examines/${context.shop_examine}/refuse`,data,isloading);
            return res;
    }

    /**
     * Remove接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
            let res:any = Http.getInstance().delete(`/shop_examines/${context.shop_examine}`,data);
            return res;
    }

    /**
     * Save接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        let masterData:any = {};
        let securityinfosData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_securityinfos'),'undefined')){
            securityinfosData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_securityinfos') as any);
            if(securityinfosData && securityinfosData.length && securityinfosData.length > 0){
                securityinfosData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.id = null;
                            if(item.hasOwnProperty('id') && item.id) item.id = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.securityinfos = securityinfosData;
        let security_infomsData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_security_infoms'),'undefined')){
            security_infomsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_security_infoms') as any);
            if(security_infomsData && security_infomsData.length && security_infomsData.length > 0){
                security_infomsData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.id = null;
                            if(item.hasOwnProperty('id') && item.id) item.id = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.security_infoms = security_infomsData;
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().post(`/shop_examines/${context.shop_examine}/save`,data,isloading);
                        this.tempStorage.setItem(context.srfsessionkey+'_securityinfos',JSON.stringify(res.data.securityinfos?res.data.securityinfos:[]));
            this.tempStorage.setItem(context.srfsessionkey+'_security_infoms',JSON.stringify(res.data.security_infoms?res.data.security_infoms:[]));

            return res;
    }

    /**
     * Update接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        let masterData:any = {};
        let securityinfosData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_securityinfos'),'undefined')){
            securityinfosData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_securityinfos') as any);
            if(securityinfosData && securityinfosData.length && securityinfosData.length > 0){
                securityinfosData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.id = null;
                            if(item.hasOwnProperty('id') && item.id) item.id = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.securityinfos = securityinfosData;
        let security_infomsData:any = [];
        if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_security_infoms'),'undefined')){
            security_infomsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_security_infoms') as any);
            if(security_infomsData && security_infomsData.length && security_infomsData.length > 0){
                security_infomsData.forEach((item:any) => {
                    if(item.srffrontuf){
                        if(Object.is(item.srffrontuf,"0")){
                            item.id = null;
                            if(item.hasOwnProperty('id') && item.id) item.id = null;
                        }
                        delete item.srffrontuf;
                    }
                });
            }
        }
        masterData.security_infoms = security_infomsData;
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().put(`/shop_examines/${context.shop_examine}`,data,isloading);
                        this.tempStorage.setItem(context.srfsessionkey+'_securityinfos',JSON.stringify(res.data.securityinfos?res.data.securityinfos:[]));
            this.tempStorage.setItem(context.srfsessionkey+'_security_infoms',JSON.stringify(res.data.security_infoms?res.data.security_infoms:[]));

            return res;
    }

    /**
     * FetchCurExamine接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async FetchCurExamine(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/shop_examines/fetchcurexamine`,tempData,isloading);
        return res;
    }

    /**
     * FetchDefault接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/shop_examines/fetchdefault`,tempData,isloading);
        return res;
    }

    /**
     * FetchPendingReview接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async FetchPendingReview(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/shop_examines/fetchpendingreview`,tempData,isloading);
        return res;
    }

    /**
     * FetchTempCurExamine接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async FetchTempCurExamine(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
    }

    /**
     * FetchTempDefault接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async FetchTempDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
    }

    /**
     * FetchTempPendingReview接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async FetchTempPendingReview(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
    }

    /**
     * Select接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof Shop_examineServiceBase
     */
    public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
            let res:any = Http.getInstance().get(`/shop_examines/${context.shop_examine}/select`,isloading);
            
            return res;
    }
}
